from datetime import datetime


class PowerData:
    def __init__(self, sn_id, grid_voltage, grid_voltage_harmonic_distortion, grid_frequency, output_voltage,
                 grid_current,
                 grid_active_power, grid_reactive_power, grid_apparent_power, grid_power_factor, ups_voltage,
                 ups_current,
                 ups_frequency, ups_active_power, ups_reactive_power, ups_apparent_power, ups_power_factor,
                 bus_voltage):
        self.sn_id = sn_id
        self.grid_voltage = grid_voltage
        self.grid_voltage_harmonic_distortion = grid_voltage_harmonic_distortion
        self.grid_frequency = grid_frequency
        self.output_voltage = output_voltage
        self.grid_current = grid_current
        self.grid_active_power = grid_active_power
        self.grid_reactive_power = grid_reactive_power
        self.grid_apparent_power = grid_apparent_power
        self.grid_power_factor = grid_power_factor
        self.ups_voltage = ups_voltage
        self.ups_current = ups_current
        self.ups_frequency = ups_frequency
        self.ups_active_power = ups_active_power
        self.ups_reactive_power = ups_reactive_power
        self.ups_apparent_power = ups_apparent_power
        self.ups_power_factor = ups_power_factor
        self.bus_voltage = bus_voltage
        self.create_time = datetime.now()  # 当前时间

# 创建一个 PowerData 对象
# data = PowerData(
#     sn_id="SN123",
#     grid_voltage=220,
#     grid_voltage_harmonic_distortion=5,
#     grid_frequency=50,
#     output_voltage=230,
#     grid_current=10,
#     grid_active_power=2000,
#     grid_reactive_power=500,
#     grid_apparent_power=2100,
#     grid_power_factor=0.95,
#     ups_voltage=230,
#     ups_current=10,
#     ups_frequency=50,
#     ups_active_power=2000,
#     ups_reactive_power=500,
#     ups_apparent_power=2100,
#     ups_power_factor=0.95,
#     bus_voltage=380
# )
#
# # 访问 PowerData 对象的属性
# print("SN ID:", data.sn_id)
# print("Grid Voltage:", data.grid_voltage)
# print("Create Time:", data.create_time)
